package org.singledog.form.builder.parser.freemarker.parser;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.singledog.form.builder.ComponentType;
import org.singledog.form.builder.parser.freemarker.view.ButtonView;
import org.singledog.form.builder.view.View;

/**
 * @author adam
 * @date 2020/6/18
 */
public class ButtonViewParser extends AbstractFreemarkerParser {
    @Override
    public ComponentType supportType() {
        return ComponentType.button;
    }

    @Override
    public View parseView(String code) {
        String schema = getSchema(code);
        JSONObject object = JSON.parseObject(schema);
        return new ButtonView(code, object);
    }
}
